package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC1154 {
    public long startExecuteTime = System.currentTimeMillis();


    /**
     * 谁家冬至还不吃顿饺子了~
     * 2021-12-21 冬至快乐！
     */
    class Solution {
        public int dayOfYear(String date) {
            int ans = 0;

            int[] monthDaySum = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            String[] dataArr = date.split("-");
            int year = Integer.parseInt(dataArr[0]);
            int month = Integer.parseInt(dataArr[1]);
            int days = Integer.parseInt(dataArr[2]);

            for (int i = 1; i < month; i++) {
                ans += monthDaySum[i - 1];
            }
            // 判断是否为闰年
            boolean isLeap = false;
            if ((year % 4 == 0 && year % 100 != 0) || (year % 400) == 0) {
                isLeap = true;
            }

            if (month > 2 && isLeap) {
                ans++;
            }
            // 加上Days
            return ans + days;
        }
    }

    public void run() {
        Solution solution = new Solution();
        int[] arr = InputUtil.toIntegerArray("[1,2,3]");
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC1154 an = new LC1154();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
